package com.xsd.awen.utils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateUtils {

    private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyyMMdd");
    private static final SimpleDateFormat SDF_TIME = new SimpleDateFormat("HHmmss");

    public static String format(Date date){
        return SDF.format(date);
    }

    public static String formatTime(Date date){
        return SDF.format(date);
    }

    public static Date now(){
        return new Date();
    }

    /**
     * 减少一秒
     * @return
     */
    public static Date subOneSec(Date date){
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.SECOND, -1);
        return calendar.getTime();
    }

}
